# -*- coding: utf-8 -*-

"""
* Copyright (C) 2016 GridSafe, Inc.
"""
from django import forms
from apps.wallet.models.community import Share


class LoginForm(forms.Form):
    style = 'form-control input-lg'
    email = forms.CharField(
        widget=forms.TextInput(attrs={'placeholder': 'Email 或 手机号',
                                      'class': style}),
        min_length=2,
        max_length=32,
        required=True)
    password = forms.CharField(
        widget=forms.PasswordInput(
            attrs={'placeholder': '请输入密码', 'class': style}),
        min_length=6,
        required=True)


class RegisterForm(forms.Form):
    style = 'form-control input-lg'
    phone = forms.CharField(
        widget=forms.NumberInput(
            attrs={'placeholder': '手机号', 'class': style, 'id': 'phone'}),
        min_length=11,
        required=True)
    code = forms.CharField(
        widget=forms.NumberInput(attrs={'placeholder': '验证码', 'class': style}),
        min_length=4,
        max_length=4,
        required=True)
    password1 = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请输入密码',
                                          'class': style}),
        min_length=6,
        required=True)
    password2 = forms.CharField(
        widget=forms.PasswordInput(
            attrs={'placeholder': '请再次输入密码', 'class': style}),
        min_length=6,
        required=True)


class AddAccountForm(forms.Form):
    style = 'form-control input-lg'
    username = forms.CharField(
        widget=forms.NumberInput(attrs={'placeholder': '手机号',
                                        'class': style}),
        min_length=11,
        required=True)
    email = forms.EmailField(
        widget=forms.EmailInput(attrs={'placeholder': 'Email 地址',
                                       'class': style}),
        required=True)
    password1 = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请输入密码',
                                          'class': style}),
        min_length=6,
        required=True)
    password2 = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请再次输入密码',
                                          'class': style}),
        min_length=6,
        required=True)


class ResetPWForm(forms.Form):
    style = 'form-control input-lg'
    old_password = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请输入旧密码',
                                          'class': style}),
        min_length=6,
        required=True)
    password1 = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请输入新密码',
                                          'class': style}),
        min_length=6,
        required=True)
    password2 = forms.CharField(
        widget=forms.PasswordInput(attrs={'placeholder': '请再次输入新密码',
                                          'class': style}),
        min_length=6,
        required=True)


class ShareForm(forms.Form):
    style = 'form-control input-lg'
    url = forms.URLField(label='链接',
                         widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': u'链接', 'required': ''}))

    class Meta:
        model = Share
        fields = ('title', 'url')
        widgets = {
            'title': forms.TextInput(
                attrs={'class': 'form-control', 'placeholder': u'标题', 'required': '', 'autofocus': ''}),
        }
